package com.zhome.gateway.util;

import cn.hutool.core.util.ObjectUtil;

public class XssUtils {
    private XssUtils() {

    }
    public static String cleanXSSHtml(String value) {
        if(ObjectUtil.isEmpty(value)){
            return value;
        }
        value = value.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
        value = value.replaceAll("\\(", "&#40;").replaceAll("\\)", "&#41;");
        value = value.replaceAll("'", "&#39;");
        value = value.replaceAll("\"", "&#34;");
        value = value.replaceAll("`", "");
        value = value.replaceAll("eval\\((.*)\\)", "");
        value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\"");
        value = value.replaceAll("script", "");
        return value;
    }
}
